package com.naiterui.ehp.bs.agent.util;

import com.naiterui.ehp.bp.constants.CommonConstant;

/**
 * @author yiren
 * @since 2022/2/16
 */
public class RedisKeyUtil {
	public static final int CODE_KEY_TYPE_LOGIN = 1;
	public static final int CODE_KEY_TYPE_RESET_PWD = 2;
	public static final int CODE_KEY_TYPE_RESET_PHONE = 3;
    public static final String PHONE_SEND_TIME_KEY = CommonConstant.REDIS_PRE_AGENT + "ph_send_";
    // 验证码有效期
    public static final int SAVE_VERIFY_CODE = 10 * 60;
    // 短信发送间隔时间
    public static final int SEND_SPACE = 55;

    /**
     * redis key:注册，短信发送时间记录，用户每天10条发送量控制
     */
    public static final String PHONE_SEND_COUNT_KEY = CommonConstant.REDIS_PRE_AGENT + "ph_count_";
    /**
     * redis key:注册，短信发送当天时间记录，用于限制用户每天10条发送量控制
     */
    public static final String PHONE_DAY_SEND_COUNT_KEY = CommonConstant.REDIS_PRE_AGENT + "ph_day_count_";

    // 验证码发送次数限制
    public static final int SEND_MAX_COUNT = 10;

    // 验证码错误规则的redis key的count字段以及默认值
    public static final String VALID_COUNT_FIELD = "count";

    // 验证码错误规则的redis key
    public static final String VALID_KEY = CommonConstant.REDIS_PRE_AGENT + "valid_exp";

    public static final int DEFAULT_COUNT_FIELD = 20;

	/**
	 *
	 * @param phone
	 * @param type 1:登录, 2:找回密码, 3:修改手机号
	 * @return
	 */
	public static String getCodeKey(String phone, Integer type){
		return CommonConstant.REDIS_PRE_AGENT+"code|"+phone+"|"+type;
	}
	public static String getLoginTokenKey(Long agentId){
		return CommonConstant.REDIS_PRE_AGENT+"login|token|"+agentId;
	}

    /**
     * redis key：获取短信验证错误后的操作key
     */
    public static String getSmsValidUserOperatorKey(String cacheKey) {
        return cacheKey + "|key";
    }
}
